<template>
  <div>
      
      <!-- 输入框 -->
      <input type="text" v-model="kw">
      <!-- 列表 -->
      <show-list :goodsList="arr"></show-list>
  </div>
</template>

<script>
import {reqSearch} from "../../http/api"
export default {
    data(){
        return {
            //1.初始化数据
            arr:[],
            kw:''
        }
    },
    watch:{
        //3.监听kw
        kw(){
            if(this.kw===""){
                this.arr=[]
                return;
            }
            //发请求
            reqSearch({
                keywords:this.kw
            }).then(res=>{
                this.arr=res.data.list?res.data.list:[];
            })
        
        }
    }
    
}
</script>

<style>

</style>